<extend name="Public/base"/>
<block name="body">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

    <script src="__PUBLIC__/Admin/js/echarts.min.js"></script>
    <div class="main-title">
        <h2>{$meta_title}：</h2>
    </div>
    <div class="cf">
        <!-- 高级搜索 -->
        <div class="search-form cf" style="padding-left:200px;">
            <form>
                开始日期：<input type="text" id="starttime" name="name" class="text input-2x" value="" placeholder="点击选择日期"> &nbsp; &nbsp; 
                结束日期：<input type="text" id="endtime" name="select_date" class="text input-2x" value="" placeholder="点击选择日期">
                <button class="btn js-search" type="button">搜索</button>
                <button class="btn js-prev-search" type="button">查看上月统计</button>
            </form>
        </div>
    </div>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="js-detail" style="width: 1000px;height:300px; margin-top:20px;"></div>
</block>
<block name="script">
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('js-detail'));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: '打分：该分店平均分：0分',
				left: 'center'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data:['评分']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                name: '日',
                //data: dateTime,
            },
            yAxis: {
                type: 'value',
                name: '平均分'
            },
            series: [
                {
                    name:'平均分',
                    type:'line',
                    stack: '总量',
                     
                },
                
            ]
        };

        function getdetail(starttime,endtime,prev){
            var data = {};

            if(starttime && endtime){
                data.starttime = starttime;
                data.endtime = endtime;
            }

            if(prev){
                data.prev = 1;
            }

            data.sid = "{$shopInfo['sid']}";

            $.post("{:U('getdetail')}",data,function(res){
                if(res.date_time){
                    $("#starttime").val(res.date_time.starttime);
                    $("#endtime").val(res.date_time.endtime);
                }
				option.title.text = '打分：该分店平均分：'+res.avg_total+'分';
                option.xAxis.data = res.eval_day;
                option.series[0].data = res.avg_score;
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            },'json');
        }

        $(document).ready(function(){
            getdetail();
            //搜索功能
            $(".js-search").click(function() {
                var starttime = $("#starttime").val();
                var endtime = $("#endtime").val();
                getdetail(starttime,endtime);
            });

            $(".js-prev-search").click(function() {
                getdetail(0,0,1);
            });
        });
    </script>

    <script type="text/javascript">
        $('#starttime, #endtime').datetimepicker({
            format: 'yyyy-mm-dd',
            language: "zh-CN",
            minView: 2,
            autoclose: true
        });

        //导航高亮
        highlight_subnav("{:U('Shop/index')}");
    </script>
</block>